// -------------------------------------------------------------------------------------------------
// Copyright 2024 Kearn Chen, kearn.chen@aliyun.com
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// 
//     http://www.apache.org/licenses/LICENSE-2.0
// 
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// -------------------------------------------------------------------------------------------------

#include "xprintf.h"

void xfunc_output_callback(int c)
{
    *((volatile unsigned int *)0xc0000) = c;
}

void interrupt_enable(void)
{
   __asm volatile ("csrs mstatus, %0" : : "r" (0x8) ); 
   __asm volatile ("csrs mie, %0" : : "r" (0xffff) ); 
}

int main(void)
{
    xfunc_output = xfunc_output_callback;

    xprintf("RISCV Core Start...\n");

    interrupt_enable();

    while(1);
}

void handler_irq0(void)
{
    xprintf("interrupt 0 triggered!\n");
}

void handler_irq1(void)
{
    xprintf("interrupt 1 triggered!\n");
}

void handler_irq2(void)
{
    xprintf("interrupt 2 triggered!\n");
}

void handler_irq3(void)
{
    xprintf("interrupt 3 triggered!\n");
}

void handler_irq4(void)
{
    xprintf("interrupt 4 triggered!\n");
}

void handler_irq5(void)
{
    xprintf("interrupt 5 triggered!\n");
}

void handler_irq6(void)
{
    xprintf("interrupt 6 triggered!\n");
}

void handler_irq7(void)
{
    xprintf("interrupt 7 triggered!\n");
}

void handler_irq8(void)
{
    xprintf("interrupt 8 triggered!\n");
}

void handler_irq9(void)
{
    xprintf("interrupt 9 triggered!\n");
}

void handler_irq10(void)
{
    xprintf("interrupt 10 triggered!\n");
}

void handler_irq11(void)
{
    xprintf("interrupt 11 triggered!\n");
}

void handler_irq12(void)
{
    xprintf("interrupt 12 triggered!\n");
}

void handler_irq13(void)
{
    xprintf("interrupt 13 triggered!\n");
}

void handler_irq14(void)
{
    xprintf("interrupt 14 triggered!\n");
}

void handler_irq15(void)
{
    xprintf("interrupt 15 triggered!\n");
}
